<template>
	<view class="container">
		<!-- 使用 @getphonenumber 进行事件绑定 -->
		<!-- <button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号登录</button> -->
		<!-- tuo -->
		<div class="top">
			<div style="width: 100%;height: 30%"></div>
			<div class="userInfo">
				<div class="image">
					<img :src="userInfo.avatarUrl" alt="" />
				</div>
				<div class="user">
					<p >{{userInfo.nickName}}</p>
					<p >{{userInfo.phoneNumber}}</p>
				</div>
			</div>

			<div class="balance">
				<div>
					<p>{{userInfo.balance}}</p>
					<p>余额·充值</p>
				</div>
				<div>
					<p>{{userInfo.coupon.length}}</p>
					<p>优惠卷</p>
				</div>
				<div>
					<p>{{userInfo.integral}}</p>
					<p>积分</p>
				</div>
				
			</div>
		</div>

		<!-- 我的订单 -->
		<div class="myorders">
			<div class="myordersTop">
				<p>我的订单</p>
				<p @click="go_order_All">全部订单 ></p>
			</div>
			<ul class="myordersCard">
				<li>
					<img src="../../static/31daifukuan.svg" alt="" />
					<p>待付款</p>
				</li>
				<li>
					<img src="../../static/31daifahuo.svg" alt="" />
					<p>待发货</p>
				</li>
				<li>
					<img src="../../static/daishouhuo.svg" alt="" />
					<p>待收货</p>
				</li>
				<li>
					<img src="../../static/31daipingjia.svg" alt="" />
					<p>待评价</p>
				</li>
				<li>
					<img src="../../static/daishouhuo.svg" alt="" />
					<p>售后</p>
				</li>
			</ul>
		</div>
		
		<div class="myorders" style="margin-top: 10px;">
			<div class="myordersTop">
				<p>我的服务</p>
			</div>
			<ul class="myordersCard">
				<li @click="goAddress">
					<img src="../../static/shouhuodizhi.svg" alt="" />
					<p>收货地址</p>
				</li>
				<li>
					<img src="../../static/zuji.svg" alt="" />
					<p>足迹</p>
				</li>
				<li>
					<img src="../../static/wodeshoucang.svg" alt="" />
					<p>我的收藏</p>
				</li>
				<li>
					<img src="../../static/fuwuzhongxin.svg" alt="" />
					<p>服务中心</p>
				</li>
				<li>
					<img src="../../static/kefu.svg" alt="" />
					<p>在线客服</p>
				</li>
			</ul>
		</div>
	</view>
</template>

<script>
	import {
		decrypt_phone_number,
		getSessionKey
	} from '../../api/user';
	export default {
		data() {
			return {
				sessionKey: "",
				openid: '',
				userInfo:{
					coupon:{}
				}
			}
		},

		onShow() {
			this.userInfo = uni.getStorageSync('userInfo')
			console.log(this.userInfo);
			if(!this.userInfo.id){
				uni.navigateTo({
					url:"/subPackages/pages/login/index"
				})
			}
		},

		methods: {
			goAddress(){
				uni.navigateTo({
					url:"/subPackages/pages/address/index"
				})
			},
			
			// 前往查看全部订单
			go_order_All(){
				uni.navigateTo({
					url:"/subPackages/pages/order/list"
				})
			}
		}
	};
</script>

<style scoped>
	.container {
		width: 100%;
		height: 100%;
		background-color: #F9FAFC;
	}

	.top {
		background-color: #68B34C;
		width: 100%;
		height: 40%;
	}

	.userInfo {
		width: 100%;
		height: 30%;
		display: flex;
		align-items: center;
		padding: 10px;
		box-sizing: border-box;
	}

	.userInfo .image {
		height: 100%;
		aspect-ratio: 1 / 1;
		background-color: aqua;
		border-radius: 50%;
		margin-right: 10px;
		border: 2px solid #fff;
		box-sizing: border-box;
		overflow: hidden;
	}

	.userInfo .image img {
		width: 100%;
		height: 100%;
		border-radius: 50%;
	}

	.userInfo .user {
		color: #fff;
		font-weight: 700;
	}

	.userInfo .user p:nth-child(2) {
		font-size: 12px;
		font-weight: 400;
		margin-top: 5px;
	}
	
	.userInfo .user button {
		border: 1px solid none;
		background-color: #68B34C;
		padding: 0;
		font-size: 18px;
		font-weight: 600;
		color: #fff;
	}

	.balance {
		display: flex;
		justify-content: space-between;
		padding: 10px 30px;
		box-sizing: border-box;
		color: #fff;
	}

	.balance div {
		text-align: center;
	}

	.balance div p:nth-child(1) {
		margin-bottom: 3 px;
		font-size: 18px;
	}

	.balance div p:nth-child(2) {
		font-size: 12px;
	}

	.myorders {
		width: 90%;
		height: 150px;
		background-color: #fff;
		border-radius: 10px;
		margin: auto;
		margin-top: -50px;
		padding: 10px;
		box-sizing: border-box;
	}
	
	.myorders .myordersTop {
		display: flex;
		justify-content: space-between;
		width: 100%;
		height: 30px;
		font-weight: 600;
		color: #333;
		font-size: 14px;
	}
	
	.myorders .myordersTop p:nth-child(2) {
		font-size: 12px;
		color: #888;
	}
	
	.myorders .myordersCard {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		height: calc(100% - 30px);
	}
	
	.myorders .myordersCard li {
		width: 19%;
		text-align: center;
	}
	
	.myorders .myordersCard li img {
		width: 30px;
		height: 30px;
	}
	.myorders .myordersCard li p {
		font-size: 14px;
		color: #333;
		margin-top: 5px;
	}
</style>